<?php
	require_once("../conexion/conexion.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<script src="../include_js/jquery.js" type="text/javascript"></script>
<script>
function Direccionar()
{
	$.ajax({
			type: 'POST',
			url: 'Contabilidad/Carga_Busqueda_Rendicion.php',
			data: $('#form_Rendicion').serialize(),
			success: function(data) {
				$('#busqueda').html(data);
			}
		})
}

function Eliminar(valor)
{
	//id = document.getElementById("tbRendicion").rows[valor].cells[0].innerText;
	//alert(valor);
	$.ajax({
		type: 'POST',
		url: 'Contabilidad/Eliminar_Rendicion.php',
		data: {id:valor},
		success: function(data) {
			$('#eliminar').html(data);
			Direccionar();
		}
	})
}
</script>
<style>
.texto
{
	font-size:14px;
	margin-left:10px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}


</style>
</head>

<body>
<form name="form_busqueda" id="form_busqueda" method="post">
<?php
	extract($_POST); 	
	$cont = 0;


	$FechaIni = explode("-", $txtFIni);
	$txtFIni = "$FechaIni[2]-$FechaIni[1]-$FechaIni[0]";

	$FechaFin = explode("-", $txtFFin);
	$txtFFin = "$FechaFin[2]-$FechaFin[1]-$FechaFin[0]";

	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select RenId,RenPersona,RenObs,date_format(RenFecha,'%d/%m/%Y') as fecha,RenMonto,RenVuelto,RenEstado from rendicion where ((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(RenFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."') order by RenId asc";
	$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$fila = mysql_num_rows($res);  
	if($fila>0)
	{
?>
<div class='groupbox'>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno">
<tr><td class="borde"><div style="float:left; clear:none; margin-top:5px;"><label class="texto" style="font-weight:bold;">Rendiciones Ingresadas.</label></div></td></tr>
<tr><td class="borde">&nbsp;</td></tr>
<tr><td class="borde"><div align="center" class="cabecera">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno" id="tbRendicion">
	<thead>
	<tr>
		<th width="3%">id</th>
		<th width="22%">responsable</th>
		<th width="25%">motivo</th>
		<th width="12%">fecha</th>
		<th width="12%">monto</th>
		<th width="12%">vuelto</th>
		<th width="12%">estado</th>
		<th>&nbsp;</th>
	</tr>
	</thead>
	<?php
		$aux=1;
		while($row = mysql_fetch_row($res))
		{
			if($row[6]=='PENDIENTE')
			{ $estado =  "<label style='color:#C00; font-weight:bold;'>".$row[6]."</label>";}
			else
			{	$estado = "<label style='color:#00C; font-weight:bold;'>".$row[6]."</label>";}
				
			if(($aux % 2)==0)
			{
				echo "<tr class='filaPar'>";
				echo "<td width=\"5%\" style=\"text-align:center;\">".$row[0]."</td>";
				echo "<td width=\"22%\" style='text-align:left;padding-left:5px;'>".$row[1]."</td>";
				echo "<td width=\"25%\" style='text-align:left;padding-left:5px;'>".$row[2]."</td>";
				echo "<td width=\"12%\" style='text-align:center;'>".$row[3]."</td>";
				echo "<td width=\"12%\" style='text-align:right;padding-right:15px;'>$".number_format ($row[4],0,',','.')."</td>";
				echo "<td width=\"12%\" style='text-align:right;padding-right:20px;'>$".number_format ($row[5],0,',','.')."</td>";
				echo "<td width=\"12%\" style='text-align:center;'>".$estado."</td>";
				echo "<td style='text-align:center;'><img src='imagen/delete_icon.gif' width='16' height='16' alt='Eliminar' style='cursor: pointer;' onclick='Eliminar($row[0]);'/></td>";
				echo "</tr>";
			}
			else
			{
				echo "<tr class='filaImpar'>";
				echo "<td width=\"5%\" style=\"text-align:center;\">".$row[0]."</td>";
				echo "<td width=\"22%\" style='text-align:left;padding-left:5px;'>".$row[1]."</td>";
				echo "<td width=\"25%\" style='text-align:left;padding-left:5px;'>".$row[2]."</td>";
				echo "<td width=\"12%\" style='text-align:center;'>".$row[3]."</td>";
				echo "<td width=\"12%\" style='text-align:right;padding-right:15px;'>$".number_format ($row[4],0,',','.')."</td>";
				echo "<td width=\"12%\" style='text-align:right;padding-right:20px;'>$".number_format ($row[5],0,',','.')."</td>";
				echo "<td width=\"12%\" style='text-align:center;'>".$estado."</td>";
				echo "<td style='text-align:center;'><img src='imagen/delete_icon.gif' width='16' height='16' alt='Eliminar' style='cursor: pointer;' onclick='Eliminar($row[0]);'/></td>";
				echo "</tr>";
			}
		$aux++;
	}
			?>
	</table>
    </div>
</td></tr>
</table>
</div>
<?php	}
	else
		{echo "<label style='color:#C00; font-weight:bold;'>B&Uacute;SQUEDA SIN RESULTADOS</label>";}
?>
</form>
<div id="eliminar"></div>
</body>
</html>
